package GUI;

import java.awt.Dimension;
import java.awt.Point;
import java.util.List;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;

import com.itextpdf.text.log.SysoLogger;

import core.model.Carrito;
import core.model.Lista;
import core.thread.TablaPDF;

import GUI.manager.VentanaFactory;
import GUI.manager.VentanaManager;

public class panelHistorial extends javax.swing.JPanel implements
		ActionListener, MouseListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4536099560597652574L;
	private VentanaManager ventanaManager=VentanaFactory.getInstance();
	private java.util.List<Lista> listas=ventanaManager.getallListas();
	private DefaultTableModel modelo=new DefaultTableModel(convertirArray(listas), new Object[]{"Codigo","Autor","Titulo","Fecha"});
	private Point punto=new Point();
	private String nombre_usuario;
	private static List<Carrito> carritos;
    public static int codigo_lista;
    public static int autor;
		
	public panelHistorial() {
		initComponents();
	}

	private void initComponents() {
		bTitulo = new javax.swing.JButton();
        etiquetaNick = new javax.swing.JLabel();
        botonSalir = new javax.swing.JButton();
        panelCentro = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        bModificarLista = new javax.swing.JButton();
        bEnviar = new javax.swing.JButton();
        bEliminar = new javax.swing.JButton();
        bGuardar = new javax.swing.JButton();
        bVer = new javax.swing.JButton();
        etiquetaEntrada = new javax.swing.JLabel();
        bCrearLista = new javax.swing.JButton();
        bOpciones = new javax.swing.JButton();
        bSugerencias = new javax.swing.JButton();
        bHistorial = new javax.swing.JButton();
        bAyuda = new javax.swing.JButton();
        bBusqueda = new javax.swing.JButton();

		setBackground(new java.awt.Color(255, 255, 255));

		bTitulo.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/encabezadoMain.png")); // NOI18N
		bTitulo.setBorder(null);
		bTitulo.setBorderPainted(false);
		bTitulo.addActionListener(this);
		bTitulo.setBackground(new java.awt.Color(255, 255, 255));

		bModificarLista.setBackground(new java.awt.Color(255, 255, 255));
		bModificarLista.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
		bModificarLista.setForeground(new java.awt.Color(243, 15, 120));
		bModificarLista.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonModificar.png")); // NOI18N
		bModificarLista.setBorder(null);
		bModificarLista.addActionListener(this);
		bModificarLista.setEnabled(false);

		bEnviar.setBackground(new java.awt.Color(255, 255, 255));
		bEnviar.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
		bEnviar.setForeground(new java.awt.Color(243, 15, 120));
		bEnviar.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonEnviar.png")); // NOI18N
		bEnviar.setEnabled(false);
		bEnviar.setBorder(null);
		bEnviar.addActionListener(this);
		
		bGuardar.setBackground(new java.awt.Color(255, 255, 255));
        bGuardar.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
        bGuardar.setForeground(new java.awt.Color(243, 15, 120));
        bGuardar.setIcon(new javax.swing.ImageIcon("src/GUI/resources/botonGuardar.png")); // NOI18N
        bGuardar.setBorder(null);
        bGuardar.addActionListener(this);
        bGuardar.setEnabled(false);

		bEliminar.setBackground(new java.awt.Color(255, 255, 255));
		bEliminar.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
		bEliminar.setForeground(new java.awt.Color(243, 15, 120));
		bEliminar.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonEliminar.png")); // NOI18N
		bEliminar.setBorder(null);
		bEliminar.addActionListener(this);
		bEliminar.setEnabled(false);

		bSugerencias.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bSugerencias.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonSugerencias.png")); // NOI18N
		bSugerencias.setBorderPainted(false);
		bSugerencias.addActionListener(this);
		bSugerencias.setBackground(new java.awt.Color(255, 255, 255));

		bCrearLista.setBackground(new java.awt.Color(255, 255, 255));
		bCrearLista.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bCrearLista.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonCrearLista.png")); // NOI18N
		bCrearLista.setBorderPainted(false);
		bCrearLista.addActionListener(this);

		bHistorial.setBackground(new java.awt.Color(255, 255, 255));
		bHistorial.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bHistorial.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonHistorial.png")); // NOI18N
		bHistorial.setBorderPainted(false);
		bHistorial.addActionListener(this);

		etiquetaNick.setBackground(new java.awt.Color(102, 102, 102));
		etiquetaNick.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaNick.setText(panelPrincipal.nick);
		etiquetaNick.setToolTipText("");

		botonSalir.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/menu-salir.png")); // NOI18N
		botonSalir.setBorderPainted(false);
		botonSalir.addActionListener(this);
		botonSalir.setBackground(new java.awt.Color(255, 255, 255));

		panelCentro.setBackground(new java.awt.Color(255, 255, 255));
		
		bVer.setBackground(new java.awt.Color(255, 255, 255));
        bVer.setFont(new java.awt.Font("Lucida Handwriting", 1, 14)); // NOI18N
        bVer.setForeground(new java.awt.Color(243, 15, 120));
        bVer.setIcon(new javax.swing.ImageIcon("src/GUI/resources/botonVer.png")); // NOI18N
        bVer.setBorder(null);
        bVer.addActionListener(this);
        bVer.setEnabled(false);
        

		

		jTable1.setModel(modelo);
		jTable1.addMouseListener(this);
		jTable1.addMouseListener(new MouseAdapter() 
		   {
		      public void mouseClicked(MouseEvent e) 
		      
		      {
		    	  bEnviar.setEnabled(false);
		         	bGuardar.setEnabled(false);
		         	bEliminar.setEnabled(false);
		         	bModificarLista.setEnabled(false);
		         	bVer.setEnabled(false);
		         int fila = jTable1.rowAtPoint(e.getPoint());
		         int valor=Integer.parseInt(jTable1.getValueAt(fila, 0).toString());
		         codigo_lista=valor;
		         nombre_usuario=(String) jTable1.getValueAt(fila, 1);
		         String titulo_lista=(String) jTable1.getValueAt(fila, 2);
		         panelCrearLista.titulo=titulo_lista;
		        
		         int columna = jTable1.columnAtPoint(e.getPoint());
		         
		         if((panelPrincipal.nick.equals(nombre_usuario)&&((fila > -1) && (columna > -1)))){
		        	 bEnviar.setEnabled(true);
			         	bGuardar.setEnabled(true);
			         	bEliminar.setEnabled(true);
			         	bModificarLista.setEnabled(true);
			         	bVer.setEnabled(true);
			         	
			         	
		         }
		         if ((fila > -1) && (columna > -1))
		           
		  
		         	bEnviar.setEnabled(true);
		         	bGuardar.setEnabled(true);
		         	bVer.setEnabled(true);
		         	
		      }
		   });
		jScrollPane1.setViewportView(jTable1);

		org.jdesktop.layout.GroupLayout panelCentroLayout = new org.jdesktop.layout.GroupLayout(panelCentro);
        panelCentro.setLayout(panelCentroLayout);
        panelCentroLayout.setHorizontalGroup(
            panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelCentroLayout.createSequentialGroup()
                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelCentroLayout.createSequentialGroup()
                        .add(54, 54, 54)
                        .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(panelCentroLayout.createSequentialGroup()
                                .add(bModificarLista)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(bVer)
                                .add(46, 46, 46)
                                .add(bEliminar))
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(panelCentroLayout.createSequentialGroup()
                        .add(131, 131, 131)
                        .add(bGuardar)
                        .add(59, 59, 59)
                        .add(bEnviar)))
                .addContainerGap(110, Short.MAX_VALUE))
        );
        panelCentroLayout.setVerticalGroup(
            panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelCentroLayout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 268, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, bModificarLista, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(bEliminar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(bVer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(panelCentroLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(bGuardar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(bEnviar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(45, Short.MAX_VALUE))
        );

		bOpciones.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bOpciones.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonOpciones.png")); // NOI18N
		bOpciones.setBorderPainted(false);
		bOpciones.addActionListener(this);
		bOpciones.setBackground(new java.awt.Color(255, 255, 255));

		etiquetaEntrada.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		etiquetaEntrada.setForeground(new java.awt.Color(243, 15, 120));
		etiquetaEntrada.setText("BIENVENIDO A LISTA DE LA COMPRA MAKER ");

		bBusqueda.setBackground(new java.awt.Color(255, 255, 255));
		bBusqueda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bBusqueda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonBusqueda.png")); // NOI18N
		bBusqueda.setToolTipText("");
		bBusqueda.setBorderPainted(false);
		bBusqueda.addActionListener(this);

		bAyuda.setFont(new java.awt.Font("Lucida Handwriting", 1, 13)); // NOI18N
		bAyuda.setIcon(new javax.swing.ImageIcon(
				"src/GUI/resources/botonAyuda.png")); // NOI18N
		bAyuda.setBorderPainted(false);
		bAyuda.addActionListener(this);
		bAyuda.setBackground(new java.awt.Color(255, 255, 255));

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.addContainerGap()
										.add(layout
												.createParallelGroup(
														org.jdesktop.layout.GroupLayout.LEADING)
												.add(layout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(bCrearLista,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bBusqueda,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																155,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bHistorial,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bSugerencias,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.add(bOpciones,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																157,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
												.add(org.jdesktop.layout.GroupLayout.TRAILING,
														bAyuda,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														157,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
										.add(26, 26, 26)
										.add(panelCentro,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE).add(9, 9, 9))
								.add(layout.createSequentialGroup()
										.add(96, 96, 96).add(bTitulo)
										.add(44, 44, 44).add(botonSalir))
								.add(layout
										.createSequentialGroup()
										.add(84, 84, 84)
										.add(etiquetaEntrada)
										.add(46, 46, 46)
										.add(etiquetaNick,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												280,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
						.addContainerGap(
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		layout.setVerticalGroup(layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(layout
						.createSequentialGroup()
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(bTitulo,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										104,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(botonSalir))
						.add(6, 6, 6)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(etiquetaEntrada).add(etiquetaNick))
						.add(18, 18, 18)
						.add(layout
								.createParallelGroup(
										org.jdesktop.layout.GroupLayout.LEADING)
								.add(layout
										.createSequentialGroup()
										.add(bBusqueda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bCrearLista,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bHistorial,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bSugerencias,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bOpciones,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(18, 18, 18)
										.add(bAyuda,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												41,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
								.add(panelCentro,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.addContainerGap(
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
	}

	private javax.swing.JButton bAyuda;
    private javax.swing.JButton bBusqueda;
    private javax.swing.JButton bCrearLista;
    private javax.swing.JButton bEliminar;
    private javax.swing.JButton bEnviar;
    private javax.swing.JButton bGuardar;
    private javax.swing.JButton bVer;
    private javax.swing.JButton bHistorial;
    private javax.swing.JButton bModificarLista;
    private javax.swing.JButton bOpciones;
    private javax.swing.JButton bSugerencias;
    private javax.swing.JButton bTitulo;
    private javax.swing.JButton botonSalir;
    private javax.swing.JLabel etiquetaEntrada;
    private javax.swing.JLabel etiquetaNick;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JPanel panelCentro;
	private JFrame actual;
	private JPanel estePanel = this;
	
	
	
	
	public String[][] convertirArray(java.util.List<Lista>listas)
	{
		String [][] datos=new String [listas.size()][4];
		for(int i=0;i<listas.size();i++)
		{
			datos[i][0]=String.valueOf(listas.get(i).getCodigo_lista());
			datos[i][1]=String.valueOf(listas.get(i).getNick());
			datos[i][2]=String.valueOf(listas.get(i).getTitulo());
			datos[i][3]=String.valueOf(listas.get(i).getFecha());
			
		}
		return datos;
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == bBusqueda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelBusqueda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}

		if (e.getSource() == bSugerencias) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelSugerencias());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bVer) {
			if(panelPrincipal.nick.equals(nombre_usuario)){
				autor=1;
			}else{
				autor=0;
			}
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelCrearListaEconomica(autor));
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);
			

		}
		if (e.getSource() == bOpciones) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelOpciones());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bAyuda) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelAyuda());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bCrearLista) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelCrearLista());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bTitulo) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelPrincipal());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == botonSalir) {
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelSalir(16));
			actual.setPreferredSize(new Dimension(610, 330));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bEnviar) {
		
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelEnviarPdf());
			actual.setPreferredSize(new Dimension(610, 330));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		
		if (e.getSource() == bGuardar) {
			System.out.println(punto);
			int fila=jTable1.rowAtPoint(punto);
			int codigo =Integer.parseInt(modelo.getValueAt(fila, 0).toString());
			this.codigo_lista=codigo;
			
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelGuardarPdf());
			actual.setPreferredSize(new Dimension(610, 330));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		if (e.getSource() == bModificarLista) {
			//DefaultTableModel dtm=new DefaultTableModel();
			//int fila=jTable1.rowAtPoint(punto);
			//int codigo = Integer.parseInt(jTable1.getValueAt(fila, 0).toString());
			//codigo_lista = codigo;
			
			System.out.println(codigo_lista);
			
			carritos=ventanaManager.findByLista(codigo_lista);
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelCrearListaEconomica(autor));
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);

		}
		
		if (e.getSource() == bEliminar) {
			

			
			ventanaManager.deleteLista(codigo_lista);
			modelo=new DefaultTableModel(convertirArray(listas), new Object[]{"Codigo","Autor","Titulo","Fecha"});
			jTable1.setModel(modelo);
			jTable1.updateUI();
			
			if((panelPrincipal.nick.equals(nombre_usuario))){
				
				
			}
			
			actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel);
			actual.getContentPane().remove(0);
			actual.getContentPane().add(new panelHistorial());
			actual.setPreferredSize(new Dimension(850, 630));
			actual.pack();
			actual.repaint();
			UtilidadesGUI.CentrarPantalla(actual);
		}


	}

	@Override
	public void mouseClicked(MouseEvent e) {
		punto=e.getPoint();
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
